package com.hefeng.unit.controller;

import com.hefeng.common.core.web.domain.AjaxResult;
import com.hefeng.unit.controller.entity.ParamEntity;
import com.hefeng.unit.domain.GyDeviceReport;
import com.hefeng.unit.service.GyBannerService;
import com.hefeng.unit.service.GyDeviceReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Slf4j
@RestController
@RequestMapping("/unit/main")
@Api(tags="小程序首页")
public class GyBannerController {
@Autowired
private GyDeviceReportService gyDeviceReportService;

        @Autowired
        private GyBannerService gyBannerService;

        /**
         * 方法说明: 修改用户信息
         * @Param:
         * @return:
         * @Author: fwb
         */
        @RequestMapping(value = "/getIndexData",produces = "application/json;charset=UTF-8")
        @ApiOperation("获取首页信息")
        public AjaxResult getIndexData(@RequestBody ParamEntity paramEntity){
            Map<String,Object> dataMap=new HashMap<>();
            //获取轮播图信息
            dataMap.put("bannerList",gyBannerService.getWxBannerList());
            //获取消息信息

            //获取报警列表信息
            List<GyDeviceReport> dataList=gyDeviceReportService.getReportList(paramEntity.getUserId());
            dataMap.put("reportList",dataList);
            dataMap.put("reportNumber",dataList.size());
            return  AjaxResult.success("获取成功",dataMap);
        }
    }

